package Adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.linefly.online_car.R;

import java.util.List;

import Been.been_shebei;

/**
 * Created by liheng on 2019/1/22.
 */

public class Adapter_shebei extends RecyclerView.Adapter<Adapter_shebei.ViewHolder>  {

private List<been_shebei> list1;
private item_click item_click;

public interface item_click{
    void itemclick_xiugai(int position);
    void itemclick_shanchu(int position);
    void itemclick_jingweidu(int position);
}
    public void setItemClick(Adapter_shebei.item_click itemClick){
        this.item_click = itemClick;
    }

    public Adapter_shebei(List<been_shebei> list) {
        this.list1 = list;
    }

class ViewHolder extends RecyclerView.ViewHolder {
    TextView textView_sb,textView_cp,textView_lxr,textView_hm,textView_sj,textView_sc,textView_xg,textView_jwd;

    ViewHolder(View itemView) {
        super(itemView);
        textView_sb = itemView.findViewById(R.id.shebei);
        textView_cp = itemView.findViewById(R.id.chepai);
        textView_sj = itemView.findViewById(R.id.shijian);
        textView_lxr = itemView.findViewById(R.id.lianxiren);
        textView_hm = itemView.findViewById(R.id.haoma);
        textView_sc = itemView.findViewById(R.id.shanchu);
        textView_xg = itemView.findViewById(R.id.xiugai);
        textView_jwd = itemView.findViewById(R.id.jingweidu);





    }
}



    @Override
    public Adapter_shebei.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rc_shebei, parent, false);
        Adapter_shebei.ViewHolder viewHolder = new Adapter_shebei.ViewHolder(view);
        return viewHolder;
    }


    @Override
    public void onBindViewHolder(Adapter_shebei.ViewHolder holder, final int position) {

        holder.textView_sb.setText(list1.get(position).getShebei());
        holder.textView_cp.setText(list1.get(position).getChepai());
        holder.textView_sj.setText(list1.get(position).getShijian());
        holder.textView_lxr.setText(list1.get(position).getLianxiren());
        holder.textView_hm.setText(list1.get(position).getHaoma());
        holder.textView_xg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                item_click.itemclick_xiugai(position);
            }
        });

        holder.textView_sc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                item_click.itemclick_shanchu(position);
            }
        });

        holder.textView_jwd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                item_click.itemclick_jingweidu(position);
            }
        });








    }

    @Override
    public int getItemCount() {
        return list1.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }



}
